package com.xc.hotelmgr.webapi.modules.ord.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.xc.hotelmgr.webapi.common.utils.PageUtils;
import com.xc.hotelmgr.webapi.common.utils.Query;
import com.xc.hotelmgr.webapi.modules.ord.dao.OrdOrderVODao;
import com.xc.hotelmgr.webapi.modules.ord.entity.OrdOrderVO;
import com.xc.hotelmgr.webapi.modules.ord.service.OrdOrderVOService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;



@Service("ordOrderService")
public class OrdOrderVOServiceImpl extends ServiceImpl<OrdOrderVODao, OrdOrderVO> implements OrdOrderVOService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<OrdOrderVO> page = this.page(
                new Query<OrdOrderVO>().getPage(params),
                new QueryWrapper<OrdOrderVO>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils sqlQuryPage(Map<String, Object> params) {
        String dtId = params.get("dtId").toString();
        String startTime = null;
        String endTime = null;
        List dateTime;
        dateTime = (List) params.get("dateTime");
        if(dateTime!=null) {
            startTime = dateTime.get(0).toString();
            endTime = dateTime.get(1).toString();
        }
        String ordCode = params.get("ordCode").toString();
        String phone = params.get("phone").toString();
        IPage<OrdOrderVO> page = new Query<OrdOrderVO>().getPage(params);
        List<OrdOrderVO> list = baseMapper.sqlQuryPage(page,dtId,startTime,endTime,ordCode,phone);
        PageUtils pageUtils = new  PageUtils(page,list);
        return pageUtils;
    }

}